package com;

import com.entity.dto.ApiResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ExceptionHandlerS {
    //需要处理的异常类型 ： Exception
    @ExceptionHandler(value = Exception.class)
    @ResponseBody//返回json数据给前端
    public ApiResult handler(Exception e) {
        e.printStackTrace();
        return new ApiResult(201, e.toString(), "String", null);
    }
}


